Create Programs
This chapter provides details on the syntax, structure and use of the declarations and statements supported by the KAS IDE"Integrated development environment" An integrated development environment is a type of computer software that assists computer programmers in developing software. IDEs normally consist of a source code editor, a compiler and/or interpreter, build-automation tools, and a debugger application language.
Project Structure
Structuring the application with care is important in creating your project (see Project Structure Guidelines in Advanced Topics).
IEC 61131-3 Editors
The KAS IDE programming environment provides
- Sequential Function Chart (SFC)
- Function Block Diagram (FBD)
- Free Form Ladder Diagram (FFLD)
- Structure Text (ST) and Instruction List (IL)
A more extensive description on each language can be found in the following sections of the Technical References:
- SFC"Sequential function chart" It can be used to program processes that can be split into steps. The main components of SFC are: - Steps with associated actions - Transitions with associated logic conditions - Directed links between steps and transitions must be used when you need to manage sequences of stable process states.
- Using SFC avoids complex switches and the declaration of multiple flags in programs.
- SFC must never be used as a decision diagram or flow chart for describing an algorithm (i.e. when you think “If / Then / Else...”). This leads to complex SFC charts and bad performances at run-timeIn computer science, runtime (or run-time) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). Within KAS, runtime also refers to the virtual machine that manage the program written in a computer language while it is running.
- Never use a step to represent an intermediate point within a calculation. Use ST"Structured text" A high-level language that is block structured and syntactically resembles Pascal in this case.
See also Program Limitations and the PLC Online Change feature.
Some Tips...
About Drag-and-Drop
The editor provides you with an ideal programming environment, including drag-and-drop features:
- Drag a variable from Dictionary and drop it into the program to insert it
- Drag a definition from Libraries and drop it into the program to insert its name
- Drag a block and drop it into the program to insert it (you can even select the block from an external text file).
- Drag a function block to the variable list to declare an instance
About Autocompletion
When you type the name of a function block instance (use either as an instance or a data structure), pressing the point "." after the name of the instance opens a pop-up list with the names of possible elements. Click the relevant element and validate it with the check mark.
About tooltip on variable
When you leave the mouse cursor on a variable in Editors, a tooltip is displayed to give you more details on the item.
Figure 5-76: Tooltip on Variable
The header of the tooltip displays the name of the variable and its type.
About Bookmarks
See Bookmarks
Select Function Blocks
All available Operators, functions and function blocks are listed in the Libraries toolbox. The list of available blocks is sorted into categories. The “(All)” category enables you to see the complete list of available blocks.
To insert a block in a program, select it and drag-and-drop it to the desired position in the Editor.
-
-
First drag a function block from the Libraries and drop it in the variable list (Dictionary) to declare a new instance. Then drag this instance from the Dictionary and drop it in the program.
Select Variables and Instances
Symbols of variables and instances are selected using the variable list in the Dictionary. Selecting variables is available from all editors:
- In FBD"Function block diagram" A function block diagram describes a function between input variables and output variables. A function is described as a set of elementary blocks diagrams, double-click on a variable box, an FB instance name, a contact or a coil to select the associated variable.
- In FFLD diagrams, double-click on a contact, a coil or a block input or output to select the variable. Double-click on the top of an FB rectangle to select an instance.
- When the variable editor is visible in the editor window, you can drag a variable from the list and drop it in the program to insert it.
<variable>.<Bit number> (e.g. MachineState.7
)